<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Product extends Site_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->model('products_content');
	}
	
	public function index(){
		$this->view();	
	}

	public function view(){
		
		$config['base_url'] = base_url() . 'content/product/view/';
        $config['total_rows'] = $this->products_content->getProductNum();
		$config['uri_segment'] = 4;
        $config['per_page'] = 16;

        $this->pagination->initialize($config);
		$data['data'] = $this->products_content->getProducts($this->uri->segment(4), $config['per_page']);
		
		//$data['data'] = $this->products_content->getAllProducts();
		
		$data['title']	= 'Products';
		$data['page']	= 'content/product/view';
		$data['action']	= 'Products';
		$this->load->view('layout/layout',$data);
	}
	//view detail
	public function viewDetail(){
		$row = $this->products_content->productDetail();
		$data['data'] = $row;
		$row = $row->result_array();
		
		$data['title'] = 'Product Detail';
		$data['page'] = 'product/detail';
		$data['action'] = $row[0][field('name')];
		$this->load->view('layout/layout', $data);
		}
}